package org.jeecg.modules.system.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.system.entity.TbConfig;

import java.util.List;
import java.util.Map;

/**
 * @Description: 基础配置
 * @Author: yfkj
 * @Date:   2023-03-17
 * @Version: V1.0
 */
public interface TbConfigMapper extends BaseMapper<TbConfig> {

	/**
	 * 编辑节点状态
	 * @param id
	 * @param status
	 */
	void updateTreeNodeStatus(@Param("id") String id, @Param("status") String status);

	/**
	 * 【vue3专用】根据父级ID查询树节点数据
	 *
	 * @param pid
	 * @param query
	 * @return
	 */
	List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query);

	/**
	 * 根据编码查询值
	 * @param code
	 * @return
	 */
	@Select("SELECT value FROM tb_config WHERE code = #{code,jdbcType=VARCHAR}")
	public String queryValueByCode(@Param("code")  String code);

	/**
	 * 根据上级编码查询下级所有列表
	 * @param code
	 * @return
	 */
	@Select("SELECT id,name,value,code,img,remarks FROM tb_config WHERE code LIKE CONCAT(CONCAT(#{code,jdbcType=VARCHAR}),'%') AND code != #{code,jdbcType=VARCHAR} ORDER BY code ASC ")
	public List<Map<String,Object>> queryListBySupCode(@Param("code")  String code);

}
